<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;

use Think\Controller;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends Controller
{
    //define('__PCCSS__', "__ROOT__ . '/Application/Common/Static/css'");

    //系统首页
    public function index()
    {
        if (isMobile()) {
            $this->redirect('Public/login');
        } else {
            // $this->redirect('Public/pc_login');
            $this->display('pc/index');
        }
    }
    public function getInfo()
    {
        if (is_login()) {
        }
        hook('homeIndex');
        $default_url = C('DEFUALT_HOME_URL'); //获得配置，如果为空则显示聚合，否则跳转
        if ($default_url != '' && strtolower($default_url) != 'home/index/index') {
            redirect(get_nav_url($default_url));
        }
        $this->display();
    }

    public function home()
    {
        if (is_login()) {
        }
        hook('homeIndex');
        $default_url = C('DEFUALT_HOME_URL'); //获得配置，如果为空则显示聚合，否则跳转
        if ($default_url != '' && strtolower($default_url) != 'home/index/index') {
            redirect(get_nav_url($default_url));
        }

        $show_blocks = get_kanban_config('BLOCK', 'enable', array(), 'Home');

        $this->assign('showBlocks', $show_blocks);

        $enter = modC('ENTER_URL', '', 'Home');
        $this->assign('enter', get_nav_url($enter));
        $this->display();
    }

    public function _initialize()
    {

        /*读取站点配置*/
        $config = api('Config/lists');
        C($config); //添加配置

        if (!C('WEB_SITE_CLOSE')) {
            $this->error(L('_ERROR_WEBSITE_CLOSED_'));
        }
    }
    public function denglu()
    {
        $map['username']=I('username');
        $map['password']=md5(I('password'));
        $list=M('core_userinfo_view')->where($map)->find();
        if($list){
            $_SESSION['oc_home']['uid']      = $list['uid'];
            $_SESSION['oc_home']['username'] = $list['username'];
            $_SESSION['oc_home']['nickname'] = $list['nickname'];
            $_SESSION['oc_home']['group']    = $list['group_id'];
            $_SESSION['oc_home']['class']    = $list['class_id'];
            $_SESSION['oc_home']['unit']     = $list['unit_id'];
            $this->success('登陆成功',U('index'));
        }else{
            $this->error('登录失败',U('index'));
        }
    }

}
